﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1052013, 0),
Array("", 1052014, 0),
Array("", 1052015, 0),
Array("", 1052016, 0),
Array("", 1052017, 0),
Array("", 1052018, 0),
Array("", 1052019, 0),
Array("", 1052020, 0),
Array("", 1052021, 0),
Array("", 1052022, 0),
Array("", 1052023, 0),
Array("", 1052024, 0),
Array("", 1052025, 0),
Array("", 1052026, 0),
Array("", 1052027, 0),
Array("", 1052028, 0),
Array("", 1052029, 0),
Array("", 1052030, 0),
Array("", 1052031, 0),
Array("", 1052032, 0),
Array("", 1052033, 0),
Array("", 1052034, 0),
Array("", 1052035, 0),
Array("", 1052036, 0),
Array("", 1052037, 0),
Array("", 1052038, 0),
Array("", 1052039, 0),
Array("", 1052040, 0),
Array("", 1052041, 0),
Array("", 1052042, 0),
Array("", 1052043, 0),
Array("", 1052044, 0),
Array("", 1052045, 0),
Array("", 1052046, 0),
Array("", 1052047, 0),
Array("", 1052048, 0),
Array("", 1052049, 0),
Array("", 1052050, 0),
Array("", 1052051, 0),
Array("", 1052052, 0),
Array("", 1052053, 0),
Array("", 1052055, 0),
Array("", 1052056, 0),
Array("", 1052057, 0),
Array("", 1052058, 0),
Array("", 1052059, 0),
Array("", 1052060, 0),
Array("", 1052061, 0),
Array("", 1052062, 0),
Array("", 1052067, 0),
Array("", 1052068, 0),
Array("", 1052073, 0),
Array("", 1052074, 0),
Array("", 1052077, 0),
Array("", 1052078, 0),
Array("", 1052082, 0),
Array("", 1052083, 0),
Array("", 1052084, 0),
Array("", 1052085, 0),
Array("", 1052086, 0),
Array("", 1052087, 0),
Array("", 1052089, 0),
Array("", 1052090, 0),
Array("", 1052091, 0),
Array("", 1052092, 0),
Array("", 1052093, 0),
Array("", 1052094, 0),
Array("", 1052135, 0),
Array("", 1052142, 0),
Array("", 1052143, 0),
Array("", 1052144, 0),
Array("", 1052145, 0),
Array("", 1052147, 0),
Array("", 1052151, 0),
Array("", 1052152, 0),
Array("", 1052153, 0),
Array("", 1052154, 0),
Array("", 1052168, 0),
Array("", 1052169, 0),
Array("", 1052171, 0),
Array("", 1052172, 0),
Array("", 1052175, 0),
Array("", 1052176, 0),
Array("", 1052178, 0),
Array("", 1052179, 0),
Array("", 1052180, 0),
Array("", 1052182, 0),
Array("", 1052183, 0),
Array("", 1052186, 0),
Array("", 1052193, 0),
Array("", 1052194, 0),
Array("", 1052195, 0),
Array("", 1052196, 0),
Array("", 1052197, 0),
Array("", 1052198, 0),
Array("", 1052199, 0),
Array("", 1052200, 0),
Array("", 1052201, 0),
Array("", 1052203, 0),
Array("", 1052209, 0),
Array("", 1052210, 0),
Array("", 1052213, 0),
Array("", 1052214, 0),
Array("", 1052216, 0),
Array("", 1052218, 0),
Array("", 1052224, 0),
Array("", 1052225, 0),
Array("", 1052228, 0),
Array("", 1052229, 0),
Array("", 1052230, 0),
Array("", 1052231, 0),
Array("", 1052232, 0),
Array("", 1052234, 0),
Array("", 1052236, 0),
Array("", 1052245, 0),
Array("", 1052246, 0),
Array("", 1052248, 0),
Array("", 1052253, 0),
Array("", 1052255, 0),
Array("", 1052275, 0),
Array("", 1052282, 0),
Array("", 1052283, 0),
Array("", 1052284, 0),
Array("", 1052285, 0),
Array("", 1052286, 0),
Array("", 1052289, 0),
Array("", 1052290, 0),
Array("", 1052291, 0),
Array("", 1052293, 0),
Array("", 1052294, 0),
Array("", 1052295, 0),
Array("", 1052296, 0),
Array("", 1052298, 0),
Array("", 1052306, 0),
Array("", 1052309, 0),
Array("", 1052327, 0),
Array("", 1052328, 0),
Array("", 1052330, 0),
Array("", 1052331, 0),
Array("", 1052332, 0),
Array("", 1052338, 0),
Array("", 1052339, 0),
Array("", 1052340, 0),
Array("", 1052343, 0),
Array("", 1052345, 0),
Array("", 1052346, 0),
Array("", 1052347, 0),
Array("", 1052348, 0),
Array("", 1052349, 0),
Array("", 1052354, 0),
Array("", 1052355, 0),
Array("", 1052356, 0),
Array("", 1052360, 0),
Array("", 1052367, 0),
Array("", 1052368, 0),
Array("", 1052370, 0),
Array("", 1052372, 0),
Array("", 1052373, 0),
Array("", 1052408, 0),
Array("", 1052410, 0),
Array("", 1052411, 0),
Array("", 1052412, 0),
Array("", 1052416, 0),
Array("", 1052417, 0),
Array("", 1052418, 0),
Array("", 1052419, 0),
Array("", 1052422, 0),
Array("", 1052423, 0),
Array("", 1052424, 0),
Array("", 1052425, 0),
Array("", 1052426, 0),
Array("", 1052427, 0),
Array("", 1052438, 0),
Array("", 1052439, 0),
Array("", 1052440, 0),
Array("", 1052445, 0),
Array("", 1052448, 0),
Array("", 1052449, 0),
Array("", 1052455, 0),
Array("", 1052458, 0),
Array("", 1052459, 0),
Array("", 1052503, 0),
Array("", 1052536, 0),
Array("", 1052550, 0),
Array("", 1051270, 0),
Array("", 1051271, 0),
Array("", 1051276, 0),
Array("", 1051277, 0),
Array("", 1051278, 0),
Array("", 1051279, 0),
Array("", 1051280, 0),
Array("", 1051281, 0),
Array("", 1051282, 0),
Array("", 1051284, 0),
Array("", 1051285, 0),
Array("", 1051292, 0),
Array("", 1051294, 0),
Array("", 1051295, 0),
Array("", 1051296, 0),
Array("", 1051297, 0),
Array("", 1051298, 0),
Array("", 1051299, 0),
Array("", 1052000, 0),
Array("", 1052001, 0),
Array("", 1052002, 0),
Array("", 1052003, 0),
Array("", 1052004, 0),
Array("", 1052005, 0),
Array("", 1052006, 0),
Array("", 1052007, 0),
Array("", 1052008, 0),
Array("", 1052009, 0),
Array("", 1052010, 0),
Array("", 1052011, 0),
Array("", 1052012, 0),
Array("", 1052571, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到时尚套服店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}